<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="js/serverUrl.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<script src="js/mui.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">添加实验室</h1>
		</header>
		<div class="mui-content">
			<br />
			<div class="mui-input-group">
				<div class="mui-input-row">
					<label>名称</label>
					<input type="text" id="labName" class="mui-input-clear" placeholder="">
				</div>
				<div class="mui-input-row">
					<label>门牌号</label>
					<input type="text" id="labNum" class="mui-input-clear" placeholder="">
				</div>
					<textarea id="description" rows="5" cols="20" placeholder="请填写实验室简介"></textarea>
				<br />
				<div class="mui-button-row">
					<button id="add" class="mui-btn mui-btn-danger">&nbsp;&nbsp;&nbsp;&nbsp;添加&nbsp;&nbsp;&nbsp;&nbsp;</button>
				</div>
			</div>
			
		</div>
	</body>
	<script type="text/javascript">
		document.getElementById("add").onclick = function(){
			var labJson = {};
			labJson.labID = 0;
			labJson.labName = document.getElementById("labName").value;
			labJson.labNum = document.getElementById("labNum").value;
			labJson.laderTelenumber = "";
			labJson.description = document.getElementById("description").value;
			labJson.StudentNumber = "";
			var teacherJson = JSON.parse( localStorage.getItem("userInformation") );
			var dataJson = {};
			dataJson.lab = labJson;
			dataJson.teacher = teacherJson;
			$.ajax({
				//请求方式
				type: 'POST',
				dataType: 'json',
				url: serverUrl + "CreatLab",
				headers: {
					'Content-Type': 'application/json;charset=utf-8'
				},
				data: JSON.stringify(dataJson),
				//请求成功
				success: function(data) {
					if (data == "success") {
						mui.back();
					}
				},
				//请求失败，包含具体的错误信息
				error: function(e) {
					mui.toast('遇到了未知错误！',{ duration:'long' });
				}
			});
		}
		
	</script>
</html>
